macro (generate_platform_config)

set (CFG_FILE_DIR ${CMAKE_BINARY_DIR}/Libraries/glare.core/include/)
set (CFG_FILE ${CFG_FILE_DIR}/glare.core.Config.h)

if (NOT EXISTS ${CFG_FILE})

file (WRITE ${CFG_FILE} "#define GLARE_PLATFORM_UNKNOWN		0\n")
file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM_LINUX		1\n")
file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM_WIN32		2\n")
file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM_MACOS		3\n")
file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM_ANDROID		4\n")
file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM_IOS			5\n")

file (APPEND ${CFG_FILE} "\n")

file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_UNKNOWN	0\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_MINGW	1\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_MSYS		2\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_CYGWIN	4\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_BORLAND	8\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_WATCOM	16\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_MSVC		32\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_MSVC_9	(64 | GLARE_COMPILER_MSVC)\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_MSVC_10	(128 | GLARE_COMPILER_MSVC)\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_GCC		256\n")
file (APPEND ${CFG_FILE} "#define GLARE_COMPILER_GXX		512\n")

file (APPEND ${CFG_FILE} "\n")

if (ANDROID)
				file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM GLARE_PLATFORM_ANDROID\n")
elseif (UNIX)
				file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM GLARE_PLATFORM_LINUX\n")
elseif (WIN32)
				file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM GLARE_PLATFORM_WIN32\n")
elseif (APPLE)
				file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM GLARE_PLATFORM_APPLE\n")
else ()
				file (APPEND ${CFG_FILE} "#define GLARE_PLATFORM GLARE_PLATFORM_UKNOWN\n")
endif ()

if (MINGW)
				file (APPEND ${CFG_FILE} "#define GLARE_COMPILER (GLARE_COMPILER_MINGW")
elseif (MSYS)
				file (APPEND ${CFG_FILE} "#define GLARE_COMPILER (GLARE_COMPILER_MSYS")
elseif (CYGWIN)
				file (APPEND ${CFG_FILE} "#define GLARE_COMPILER (GLARE_COMPILER_CYGWIN")
elseif (BORLAND)
				file (APPEND ${CFG_FILE} "#define GLARE_COMPILER (GLARE_COMPILER_BORLAND")
elseif (WATCOM)
				file (APPEND ${CFG_FILE} "#define GLARE_COMPILER (GLARE_COMPILER_WATCOM")
elseif (MSVC90)
				file (APPEND ${CFG_FILE} "#define GLARE_COMPILER (GLARE_COMPILER_MSVC_9")
elseif (MSVC10)
				file (APPEND ${CFG_FILE} "#define GLARE_COMPILER (GLARE_COMPILER_MSVC_10")
else ()
				file (APPEND ${CFG_FILE} "#define GLARE_COMPILER (GLARE_COMPILER_UNKNOWN")
endif ()

if (CMAKE_COMPILER_IS_GNUCC)
				file (APPEND ${CFG_FILE} " | GLARE_COMPILER_GCC")
endif ()

if (CMAKE_COMPILER_IS_GNUCXX)
				file (APPEND ${CFG_FILE} " | GLARE_COMPILER_GXX")
endif ()

file (APPEND ${CFG_FILE} ")\n\n")

if (${GLARE3D_CXX_11_FEATURES_ENABLED})
	file (APPEND ${CFG_FILE} "#define GLARE_CXX_11_FEATURES_ENABLED 1\n")
else()
	file (APPEND ${CFG_FILE} "#define GLARE_CXX_11_FEATURES_ENABLED 0\n")
endif ()

if (${GLARE3D_WIN8_APPSTORE_CLEAN})
	file (APPEND ${CFG_FILE} "#define GLARE3D_WIN8_APPSTORE_CLEAN 1\n")
else()
	file (APPEND ${CFG_FILE} "#define GLARE3D_WIN8_APPSTORE_CLEAN 0\n")
endif ()

unset (CFG_FILE)

endif()

endmacro (generate_platform_config)
